Qt compiled program prompt cannot find libxxx.dll

693 Views
No Comments

A total of 628 characters, expected to take 2 minutes to complete reading.

Reason

Qt compiled program prompt cannot find libxxx.dll

This problem occurs because the dynamic library cannot be found, so use the command windeployqt to deploy the dynamic library.

Solution

A more complete approach is visible:https://www.mcso.top/computer/programming/clion-qt-program/

Method 1: Manually add

Qt compiled program prompt cannot find libxxx.dll

This is because there is no use of Qt's Dynamic Link Library . We find QT directory \QT version number \mingw_64\bin directory, for example in my this is QT\6.7.0\mingw_64\bin, enter and create here. cmd window , enter:

# 加载环境
qtenv2.bat
# 动态链接库
windeployqt 你的文件.exe

Qt compiled program prompt cannot find libxxx.dll

Then many other files are generated in the build directory, and then the run becomes:

Qt compiled program prompt cannot find libxxx.dll

Method 2: Modify CMakeLists.txt

In CMakeLists.txt Add the following code, will 3DSystemHelper Modify the name of the executable generated for you:

add_custom_command(TARGET 3DSystemHelper POST_BUILD
        COMMAND ${CMAKE_COMMAND} -E echo "Start deploy Qt..."
        COMMAND ${CMAKE_PREFIX_PATH}/bin/qtenv2.bat
        COMMAND windeployqt ${EXECUTABLE_OUTPUT_PATH}/3DSystemHelper.exe
        COMMAND ${CMAKE_COMMAND} -E echo "Deploy Qt completed!"
)

Qt compiled program prompt cannot find libxxx.dll

Then rebuild it:

Qt compiled program prompt cannot find libxxx.dll

The result is still the same, can run:

Qt compiled program prompt cannot find libxxx.dll

END
 0
Comment(No Comments)
验证码
en_USEnglish
Article Directory